import fetch from 'utils/fetch'

export default {
  addSchool (data, options) { // 保存修改校区
    return fetch({
      url: '/train/school/saveTrainSchoolInfo',
      method: 'POST',
      data: JSON.stringify(data),
      options
    })
  },
  deleteSchool (data, options) { // 删除校区
    return fetch({
      url: '/train/school/removeTrainSchool',
      method: 'POST',
      data,
      options
    })
  },
  schoolList (params) { // 校区列表
    return fetch({
      url: '/train/school/trainSchoolPageInfo',
      params
    })
  },
  getScheduleList (params) { // 课程表
    return fetch({
      url: 'train/course/schedule/list',
      params
    })
  },
  getListCurrculum (params) { // 获取课程列表
    return fetch({
      url: '/train/course/trainCoursePageInfo',
      params
    })
  },
  trainCourseDetail (params) { // 查询课程详情&校区
    return fetch({
      url: '/train/course/trainCourseDetail',
      params
    })
  },
  listTrainClassLevelInfo (params) { // 获取班别
    return fetch({
      url: '/train/course/listTrainClassLevelInfo',
      params
    })
  },
  listStartClassTimeInfo (params) { // 获取上课时间段
    return fetch({
      url: '/train/course/ListStartClassTimeInfo',
      params
    })
  },
  listTrainClassInfo (params) { // 查询班级列表
    return fetch({
      url: '/train/course/listTrainClassInfo',
      params
    })
  },
  trainClassInfo (params) { // 获取班级详细信息
    return fetch({
      url: '/train/course/trainClassDetailById',
      params
    })
  },
  checkTeacher (params) { // 检查同一时间段，教练是否重复
    return fetch({
      url: '/train/classroom/isDuplicate',
      params
    })
  },
  classEdit (params) { // 编辑班级获取班级详情
    return fetch({
      url: '/train/classroom/to/change',
      params
    })
  },
  classStudentInfo (params) { // 根据班级ID查询班级学员
    return fetch({
      url: '/train/student/class/classStudentInfo',
      params
    })
  },
  getSchoolList (params) { // 根据课程id获取校区列表
    return fetch({
      url: '/train/course/school/list',
      params
    })
  },
  getClasstypeList (params) { // 根据课程id获取班别列表
    return fetch({
      url: '/train/course/classes/list',
      params
    })
  },
  listPageInfo  (params) { // 获取班级列表
    return fetch({
      url: '/train/classroom/listPageInfo',
      params
    })
  },
  teacherList () { // 获取所有教练
    return fetch({
      url: '/train/teacher/teacherList'
    })
  },
  classList () {
    return fetch({ // 获取所有课程
      url: '/train/course/simple/list'
    })
  },
  getAddress (params) { // 根据校区id获取上课地点
    return fetch({
      url: '/train/school/address',
      params
    })
  },
  addClassRoom (data, type) { // 新增班级
    return fetch({
      url: '/train/classroom/',
      method: type,
      data
    })
  },
  classRemove (params, options) { // 删除班级
    return fetch({
      url: '/train/classroom/',
      method: 'delete',
      params,
      options
    })
  },
  trainClassInfoShow (params) { // 班级详情
    return fetch({
      url: '/train/classroom/trainClassInfo',
      params
    })
  },
  classScheduleTimeInfo (params) { // 班级详情获取课时数量
    return fetch({
      url: '/train/classroom/classScheduleTimeInfo',
      params
    })
  },
  classScheduleInfo (params) { // 上课记录
    return fetch({
      url: '/train/classroom/classScheduleInfo',
      params
    })
  },
  studentSignUp (params) { // 插入导入报名学员
    return fetch({
      url: '/train/student/class/studentSignUp',
      params
    })
  },
  importStudent (data, options) { // 导入学员
    return fetch({
      url: '/train/student/class/importStudent',
      method: 'post',
      data,
      options
    })
  },
  coachList (params) { // 获取/查询教练管理列表
    return fetch({
      url: '/train/teacher/list',
      params
    })
  },
  editCoach (data, options) { // 新增or编辑教练
    return fetch({
      url: '/train/teacher/save',
      method: 'POST',
      data,
      options
    })
  },
  countryList (params) { // 获取国家列表
    return fetch({
      url: '/train/countryList',
      params
    })
  },
  coachCourseDetail (params) { // 获取教练授课详情
    return fetch({
      url: '/train/teacher/courseDetail',
      params
    })
  },
  coachInfo (params) { // 获取教练信息详情
    return fetch({
      url: '/train/teacher/detail',
      params
    })
  },
  studentList (params) { // 获取学员管理列表
    return fetch({
      url: '/train/student/list',
      params
    })
  },
  studentDetail (params) { // 获取学员详情
    return fetch({
      url: '/train/student/detail',
      params
    })
  },
  studentCourseList (params) { // 获取学员在上课程列表
    return fetch({
      url: '/train/student/class/detail/page',
      params
    })
  },
  studentInfo (params) { // 获取编辑的学员信息
    return fetch({
      url: '/train/student/info',
      params
    })
  },
  editStudent (data, options) { // 新增or编辑学员
    return fetch({
      url: '/train/student/',
      method: 'POST',
      data,
      options
    })
  },
  studentCourseInfo (params) {
    return fetch({
      url: '/train/student/class/detail',
      params
    })
  },
  studentCourse (params) { // 获取学员上课情况列表
    return fetch({
      url: '/train/student/class/schedule/detail',
      params
    })
  },
  getScheduleOptions (params) { // 获取课程表筛选选项
    return fetch({
      url: '/train/course/schedule/list/condition',
      params
    })
  },
  studentVacate (params) { // 学员请假课时信息
    return fetch({
      url: '/train/student/schedule/leaveList',
      params
    })
  },
  studentLeaveSchedule (params) { // 获取班级的学生课时
    return fetch({
      url: '/train/student/class/leaveSchedule',
      params
    })
  },
  studentLeave (data, options) { // 学生请假
    return fetch({
      url: '/train/student/class/leave',
      method: 'PUT',
      data,
      options
    })
  },
  studentCancelLeaveSchedule (params) { // 获取班级的学生取消请假课时
    return fetch({
      url: '/train/student/class/cancelLeaveSchedule',
      params
    })
  },
  studentCancelLeave (data, options) { // 学生撤销请假
    return fetch({
      url: '/train/student/class/cancelLeave',
      method: 'PUT',
      data,
      options
    })
  },
  studentDelete (data, options) { // 班级删除学员
    return fetch({
      url: `/train/student/class/cancelLeave?studentClassId=${data.id}`,
      method: 'DELETE',
      data,
      options
    })
  },
  studentCloseVacate (params) { // 学员撤销请假课时信息
    return fetch({
      url: '/train/student/schedule/cancelLeave',
      params
    })
  },
  studentPutVacate (data, options) { // 提交学员请假
    return fetch({
      url: '/train/student/class/leave',
      method: 'put',
      data,
      options
    })
  },
  studentPutCloseVacate (data, options) { // 提交学员撤销请假
    return fetch({
      url: '/train/student/class/cancelLeave',
      method: 'put',
      data,
      options
    })
  },
  courseTimeCount (params) { // 获取所有课时信息
    return fetch({
      url: '/train/student/count/schedule',
      params
    })
  },
  courseCampusClass (params) {
    return this.classList({}).then(res => {
      console.log(res.data)
      return res.data.map((item, index) => {
        return [
          this.getSchoolList({courseId: item.id}).then(res => {
            console.log(res.data)
            return res.data
          }),
          this.getClasstypeList({courseId: item.id}).then(result => {
            console.log(result.data)
            return result.data
          })
        ]
      })
    })
  },
  studentMakeUp (params) { // 获取学员的补课信息
    return fetch({
      url: '/train/student/schedule/makeup',
      params
    })
  },
  courseInfo (params) { // 获取补课时课程的课时信息
    return fetch({
      url: '/train/classroom/courseClassSchedule',
      params
    })
  },
  putMakeup (data, options) { // 提交学员补课
    return fetch({
      url: '/train/student/class/makeup',
      method: 'PUT',
      data,
      options
    })
  },
  removeValid (params) {
    return fetch({
      url: '/train/school/removeValidate',
      params
    })
  },
  editValidate (params) {
    return fetch({
      url: '/train/school/editVenuesAddressValidate',
      params
    })
  }
}
